package com.xr.miniprogram.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.xr.common.core.domain.BaseEntity;
import com.xr.miniprogram.domain.MiniProgramOrder;
import com.xr.miniprogram.domain.MiniProgramOrderStatus;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * description: 订单详情vo，处理状态值与订单子项
 *
 * @author: wls
 * @date: 2023/9/1 14:28
 * @version:1.0
 */
@Data
public class MiniProgramOrderVO {
    /** 订单ID */
    private Long orderId;
    /** 用户id */
    private Long miniProgramUserId;
    /** 服务详情id */
    private Long serviceId;
    /** 服务规格id */
    private Long serviceStandardsId;
    /** 服务封面图 */
    private String serviceCoverImg;
    /** 服务名称 */
    private String serviceName;
    /** 规格名 */
    private String standardsName;
    /** 购买服务次数 */
    private Long serviceNum;
    /** 总服务次数 */
    private Long serviceNumCount;
    /** 服务次数余量 */
    private Long serviceNumSurplus;
    /** 订单编号 */
    private String orderNumber;
    /** 支付单价 */
    private BigDecimal orderPrice;
    /** 订单备注 */
    private String orderRemarks;

    /** 支付时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date payTime;

    /** 服务详情版本 */
    private Long serviceSptVersion;

    /** 规格版本 */
    private Long standardsSptVersion;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /** 状态对象 */
    private MiniProgramOrderStatus orderStatus;

    /** 订单子项列表 */
    private List<MiniProgramOrderUserVO> orderUserVO;


    public MiniProgramOrder toMiniProgramOrder(){
        MiniProgramOrder item = new MiniProgramOrder();
        item.setOrderId(orderId);
        item.setMiniProgramUserId(miniProgramUserId);
        item.setServiceId(serviceId);
        item.setServiceStandardsId(serviceStandardsId);
        item.setServiceCoverImg(serviceCoverImg);
        item.setServiceName(serviceName);
        item.setStandardsName(standardsName);
        item.setServiceNum(serviceNum);
        item.setServiceNumCount(serviceNumCount);
        item.setServiceNumSurplus(serviceNumSurplus);
        item.setOrderRemarks(orderRemarks);
        item.setOrderNumber(orderNumber);
        item.setOrderPrice(orderPrice);
        item.setPayTime(payTime);
        item.setServiceSptVersion(serviceSptVersion);
        item.setStandardsSptVersion(standardsSptVersion);
        return item;
    }

    public static MiniProgramOrderVO toMiniProgramOrderVo(MiniProgramOrder item){
        MiniProgramOrderVO mpOV = new MiniProgramOrderVO();
        mpOV.setServiceId(item.getServiceId());
        mpOV.setOrderId(item.getOrderId());
        mpOV.setMiniProgramUserId(item.getMiniProgramUserId());
        mpOV.setServiceId(item.getServiceId());
        mpOV.setServiceStandardsId(item.getServiceStandardsId());
        mpOV.setServiceCoverImg(item.getServiceCoverImg());
        mpOV.setServiceName(item.getServiceName());
        mpOV.setStandardsName(item.getStandardsName());
        mpOV.setServiceNum(item.getServiceNum());
        mpOV.setServiceNumCount(item.getServiceNumCount());
        mpOV.setServiceNumSurplus(item.getServiceNumSurplus());
        mpOV.setOrderRemarks(item.getOrderRemarks());
        mpOV.setOrderNumber(item.getOrderNumber());
        mpOV.setOrderPrice(item.getOrderPrice());
        mpOV.setPayTime(item.getPayTime());
        mpOV.setServiceSptVersion(item.getServiceSptVersion());
        mpOV.setStandardsSptVersion(item.getStandardsSptVersion());
        return mpOV;
    }
}
